package com.example.day13;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author Lenovo
 */
public class SimpleDateFormatDemo {
    public static void main(String[] args) throws ParseException
    {
        Date d = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String str = sdf.format(d);
        System.out.println(str);
        System.out.println("--------");
        String str1 = "2020-01-01 12:12:12";
        SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date d1 = sdf1.parse(str1);
        System.out.println(d1);

    }
}
